import BindModel from './src/core/bindModel';
import BindAction from './src/core/bindAction';
import renderComponent from './src/core/render';
import {setData, getData} from './src/core/data';

let bindModel = BindModel(setData, getData);
let bindAction = BindAction(setData, getData);
let render = renderComponent(setData, getData);

const getInstance = (type) => {
    return (modelName) => {
        if (modelName) {
            return getData(type)[modelName];
        }
        return null;
    }
}
const removeInstance = (type) => {
    return (name) => {
        if (name) {
            let instance = getData(type);
            delete instance[name];
            setData({
                [type]: instance
            });
        }
    }
}

const getModel = getInstance('modelInstance');
const getAction = getInstance('actionInstance');
const removeModel = removeInstance('modelInstance');
const removeAction = removeInstance('actionInstance');

export {
    bindModel,
    bindAction,
    render,
    getModel,
    getAction,
    removeModel,
    removeAction
}